Closed Bug 1947767 Opened 4 months ago Closed 3 months ago

Use fuses to simplify or replace the ForOfPIC code

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
137 Branch
Tracking Status
firefox137 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 2 open bugs)

Details

Attachments

(11 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
No description provided.
Blocks: fuse
Blocks: 1935191

This makes fuses a little more robust when code messes with prototypes without
actually changing the property's value.

The callers have it available so there's no need to look it up again.

Renames PropertyChange to PropertyFlagsChange because this operation now only
covers the property flags. This is now only called when we're actually changing the
flags.

Adds separate watchPropertyModification calls for the case where defineProperty
is used to change the property's value (or both the value and the flags).

These changes help avoid unnecessary Watchtower calls.

This fixes a pre-exsting bug: the iterator must be created in the realm of the
arguments object.

OptimizeGetIteratorFuse guards against:

  1. Changes to Array.prototype[@@iterator].
  2. Changes to %ArrayIteratorPrototype%.

This patch adds a separate ArrayIteratorPrototypeFuse that covers just the second
case, and also changes OptimizeGetIteratorFuse to be dependent on this fuse.

Later patches will use this new fuse to replace ForOfPIC::Chain::tryOptimizeArrayIteratorNext.

This changes the CacheIR code to match the VM code changes from the previous patches.

Telemetry shows that the OptimizeGetIterator fuse is popped on less than 0.05% of
websites. With the first two patches in this stack this might drop even more.

The ArrayIteratorPrototype fuse is a subset of the OptimizeGetIterator fuse
so worst-case its numbers should be similar.

This micro-benchmark improves from 52 ms to 45 ms (best of 10 runs, with --spectre-mitigations=off):

function f() {
    var arr = [1];
    var t = new Date;
    for (var i = 0; i < 1_000_000; i++) {
        var res = new Set(arr);
    }
    print(new Date - t);
    return res;
}
f();

With new Int8Array(arr) it improves from 54 ms to 49 ms.

Checking the fuse is faster and simpler than the ForOfPIC code.

Severity: -- → S3
Priority: -- → P3
Severity: S3 → N/A

This way we have PropertyFlagsChange and PropertyValueChange.

The only reason for this to be fallible is the Watchtower testing code, but if we
recover from failure there we can simplify some of the callers. In particular in
NativeObject.cpp this moves the watchPropertyValueChange calls closer to the
setSlot calls.

Attachment #9466772 - Attachment description: Bug 1947767 part 4 - Fix bug with cross-realm `arguments[Symbol.iterator]`. r?mgaudet! → Bug 1947767 part 6 - Fix bug with cross-realm `arguments[Symbol.iterator]`. r?mgaudet!
Attachment #9466773 - Attachment description: Bug 1947767 part 5 - Add separate ArrayIteratorPrototypeFuse. r?mgaudet! → Bug 1947767 part 7 - Add separate ArrayIteratorPrototypeFuse. r?mgaudet!
Attachment #9466774 - Attachment description: Bug 1947767 part 6 - Replace uses of ForOfPIC with fuse checks. r?mgaudet! → Bug 1947767 part 8 - Replace uses of ForOfPIC with fuse checks. r?mgaudet!
Attachment #9466775 - Attachment description: Bug 1947767 part 7 - Remove now unused ForOfPIC and PIC code. r?mgaudet! → Bug 1947767 part 9 - Remove now unused ForOfPIC and PIC code. r?mgaudet!
Attachment #9466776 - Attachment description: Bug 1947767 part 8 - Make some functions infallible. r?mgaudet! → Bug 1947767 part 10 - Make some functions infallible. r?mgaudet!
Attachment #9466777 - Attachment description: Bug 1947767 part 9 - Rely on fuses in CacheIR code. r?mgaudet! → Bug 1947767 part 11 - Rely on fuses in CacheIR code. r?mgaudet!
Attachment #9466773 - Attachment description: Bug 1947767 part 7 - Add separate ArrayIteratorPrototypeFuse. r?mgaudet! → Bug 1947767 part 7 - Add separate OptimizeArrayIteratorPrototypeFuse. r?mgaudet!
Keywords: leave-open
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f9ea525db663 part 1 - Ignore no-op property modifications in Watchtower. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/fb467cb72422 part 2 - Pass PropertyInfo to watchPropertyChange. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/5584386646bc part 3 - Simplify Watchtower::watchPropertyChange. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/3692e56920cc part 4 - Rename PropertyModification hook to PropertyValueChange. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/5db74dbc123f part 5 - Make Watchtower::watchPropertyValueChange infallible. r=mgaudet
Keywords: leave-open
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c617c71a16ae part 6 - Fix bug with cross-realm `arguments[Symbol.iterator]`. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/ffc35ef730e4 part 7 - Add separate OptimizeArrayIteratorPrototypeFuse. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/23cb8e597ba8 part 8 - Replace uses of ForOfPIC with fuse checks. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/4c817911289e part 9 - Remove now unused ForOfPIC and PIC code. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/f5cf04c3b582 part 10 - Make some functions infallible. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/2a0b3de2486f part 11 - Rely on fuses in CacheIR code. r=mgaudet

(In reply to Pulsebot from comment #15)

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c617c71a16ae
part 6 - Fix bug with cross-realm arguments[Symbol.iterator]. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/ffc35ef730e4
part 7 - Add separate OptimizeArrayIteratorPrototypeFuse. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/23cb8e597ba8
part 8 - Replace uses of ForOfPIC with fuse checks. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/4c817911289e
part 9 - Remove now unused ForOfPIC and PIC code. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/f5cf04c3b582
part 10 - Make some functions infallible. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/2a0b3de2486f
part 11 - Rely on fuses in CacheIR code. r=mgaudet

This lead to a 512 byte increase in BAse contetn JS opt fission on MacOS and Linux.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: